package LeetCode.LeetCode2;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author lumin
 * @date 2022/05/05 11:20
 **/
class myCom implements Comparator<int[]> {
    public int compare(int[] o1, int[] o2) {
        return o1[0] - o2[0];
    }
}
public class Num453 {
    public int eraseOverlapIntervals(int[][] intervals) {
        Arrays.sort(intervals,new myCom());
        int num = 0;
        int i = 0;
        for (int j = 1; j < intervals.length; j++) {
            if(intervals[j][0] >= intervals[i][1]){
                i = j;
            }else{
                i = j;
                num++;
            }
        }
        return num;
    }
}